//
//  set_nolineItem.m
//  SoundPill
//
//  Created by 宋鹏鹏 on 15/4/10.
//  Copyright (c) 2015年 宋旭东. All rights reserved.
//

#import "set_nolineItem.h"

#define kDeviceHeight [UIScreen mainScreen].bounds.size.height
#define kDeviceWidth  [UIScreen mainScreen].bounds.size.width

#define kTitleScale 0.7
// 设置宽高
#define kMenuItemW kDeviceWidth
#define kMenuItemH 44

@implementation set_nolineItem

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // 1.文字颜色
        [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        self.titleLabel.textAlignment = NSTextAlignmentLeft;
        self.titleLabel.font = [UIFont systemFontOfSize:17];
        
        // 2.设置图标
        // [self setImage:[UIImage imageNamed:@"ic_arrow_down.png"] forState:UIControlStateNormal];
        
        
        //
        _textLabel = [[UILabel alloc]initWithFrame:CGRectMake(kMenuItemW*0.3,6, kMenuItemW*0.57, 32)];
        _textLabel.backgroundColor=[UIColor clearColor];
        _textLabel.font = [UIFont systemFontOfSize:13];
        _textLabel.textColor = [UIColor lightGrayColor];
        _textLabel.textAlignment = NSTextAlignmentRight;
        
        
        [self addSubview:_textLabel];

        
        self.imageView.contentMode = UIViewContentModeScaleAspectFit;
        
        
        [self setImage:[UIImage imageNamed:@"set_arrow"] forState:UIControlStateNormal];
        [self setImage:[UIImage imageNamed:@"set_arrow"] forState:UIControlStateHighlighted];
        
        UIImage *downImg = [UIImage imageNamed:@"gray_line"];
        UIImageView *downDivider = [[UIImageView alloc] initWithImage:downImg];
        downDivider.bounds = CGRectMake(0,0, kMenuItemW, 1 );
        downDivider.center = CGPointMake(kMenuItemW/2, frame.size.height-0.5);
        [self addSubview:downDivider];
        
    }
    return self;
}

- (void)setTitle:(NSString *)title
{
    _title = title;
    
    [self setTitle:title forState:UIControlStateNormal];
}

//- (void)setFrame:(CGRect)frame
//{
//    frame.size = CGSizeMake(kMenuItemW, kMenuItemH);
//    [super setFrame:frame];
//}

- (CGRect)titleRectForContentRect:(CGRect)contentRect
{
//    CGFloat h = contentRect.size.height;
//    CGFloat w = contentRect.size.width*0.25;
//    return CGRectMake(contentRect.size.width * 0.04, 0, w, h);
    return CGRectMake(17, 0, 100, contentRect.size.height);
}

- (CGRect)imageRectForContentRect:(CGRect)contentRect
{
    CGFloat h = contentRect.size.height*0.4;
    CGFloat w = 25;
    
    return CGRectMake(contentRect.size.width-30, contentRect.size.height*0.3, w, h);
}


@end
